<script setup lang="ts">
import {message} from "ant-design-vue";
import {WxtBizCode} from "~/contentScripts/views/wxt/lib/wxtUtils";
import CrowdOptimizationContent
  from "~/contentScripts/views/wxt/SuperOptimization/KeywordPromotion/CrowdOptimizationContent.vue";
import KeywordsOptimizationContent
  from "~/contentScripts/views/wxt/SuperOptimization/KeywordPromotion/KeywordPromotionUnitContent/KeywordsOptimizationContent.vue";
import ProvincialOptimizationContent
  from "~/contentScripts/views/wxt/SuperOptimization/KeywordPromotion/ProvincialOptimizationContent.vue";
import WxtModal from "~/contentScripts/views/wxt/wxt-modal.vue";

const title = '关键词优化';

const props = defineProps({
  visible: {
    type: Boolean,
    default: false,
  },
  type: {
    type: String,
    default: 'plan',
  },
  campaignIds:{
    type: Array,
    default: () => []
  },
  rows: {
    type: Array,
    default: () => []
  },
  bizCode: {
    type: String as PropType<WxtBizCode>,
    default: WxtBizCode.关键字推广,
  },
});
const emit = defineEmits([
  "refresh",
]);

const handle = () => {
  if (props.rows.length === 0) {
    message.error('请选择需要批量处理的数据！');
    return;
  }
  visible.value = true;
}
const visible = ref<boolean>(false);
</script>

<template>
  <div @click="handle">
    <slot>
      <a-button type="primary" size="small" ghost>关键词优化</a-button>
    </slot>
  </div>
  <wxt-modal :title="title" v-model:visible="visible" width="95%">
    <KeywordsOptimizationContent :biz-code="bizCode" :campaign-ids="rows.map((row)=>{
      return row.campaignId;
    })" :adgroupIds="rows.map((row)=>{
      return row.adgroupId;
    })"/>
  </wxt-modal>
</template>

<style scoped>

</style>
